// pages/basic-page/basic-page.js
Page({
    data: {
        showLoadingState:false,
        //头像
        userProfile:'https://pic1.imgdb.cn/item/63650a4116f2c2beb1e3a16a.png',
        //名字
        userName:'张三',
        //学号
        studentId:12345,

        //图像
        p5:"https://pic.imgdb.cn/item/62dfd590f54cd3f93781593d.png",
        p6:"https://pic.imgdb.cn/item/62dfd590f54cd3f937815955.png",
        p7:"https://pic.imgdb.cn/item/62dfd590f54cd3f937815904.png",
        p8:"https://pic.imgdb.cn/item/62dfd590f54cd3f93781592a.png",
        p9:"https://pic.imgdb.cn/item/62dfd88bf54cd3f937934a0d.png",
    },
    onLoad(options) {
        //从globaldata中获取用户各种信息
        var userinfo = getApp().globalData.userInfo;
        this.setData({
            'userProfile':userinfo.userProfile,
            'userName':userinfo.userName,
            'studentId':userinfo.studentId,
        })
    },
    onChangeUserProfile:function(e){
        wx.showModal({
          title:"暂不支持更改头像，敬请期待"
        })
        // var that = this;
        // var picUrl = e.detail.avatarUrl;
        // var studentid = getApp().globalData.userInfo.studentId;
        // console.log(picUrl);
        // getApp().onTest(picUrl);



        // // *********************************************************
        //     //将地址转化为base64


        // // *********************************************************



        // that.onShowLoading();
        // wx.request({
        //     url: getApp().globalData.serverUrl,
        //     method:"GET",
        //     timeout:4000,
        //     data:{
        //       //各种数据的传送
        //       operation:"CHANGE_PROFILE",
        //       studentId:studentid,
        //       userProfile:picUrl,
        //     },
        //     success(res){
        //       if(res.data == false){
        //           that.onHideLoading();
        //           wx.showModal({
        //               showCancel:false,
        //               title:"请求失败,请重试",
        //           });
        //       }
        //       else{
        //           //成功获取到信息后的操作
        //         that.setData({
        //             "userProfile":picUrl,
        //         });
        //         getApp().globalData.userInfo.userProfile = picUrl;
        //       }
        //       that.onHideLoading();
        //     },
        //     fail(res){
        //         that.onHideLoading();
        //       wx.showModal({
        //           showCancel:false,
        //           title:"请求超时,请重试",
        //       });
        //     },
        // });
    },
    onShowLoading:function(e){
        var that = this;
        wx.showLoading({
          title: '加载中',
          mask:true,
          success(res){
              that.setData({
                  "showLoadingState":true,
              })
          }
        })
        setTimeout(that.onHideLoading,4200)
    },
    onHideLoading:function(e){
        var that = this;
        if(that.data.showLoadingState == true){
            wx.hideLoading();
            that.setData({ 
                "showLoadingState":false,
            })
        }
    },
 })